let vm = new Vue({
    el: '.container',  //选中整个main
    data() {
        return {
            render: 'kaptcha/render',
            username: 'admin',
            password: 'admin',
            code: '',
            remberMe:false
        }
    },
    methods: {
        refresh: function () {
            this.render = this.render + "?" + new Date();
        },
        login: function () {
            axios({
                url: `user/login/${this.remberMe}`,
                params: {
                    username: this.username,
                    password: this.password,
                    code: this.code
                }
            }).then(response => {
                //不成功提示
                if (response.data.success) {
                    //把登陆成功的用户存到session去
                    let user = JSON.stringify(response.data.obj);
                    console.log(user)
                    sessionStorage.setItem("user", user);
                    location.href = 'html/home.html'
                    // layer.msg("登陆成功")
                } else {
                    //登陆失败
                    layer.msg(response.data.msg);
                    //刷新验证码
                    this.refresh();
                }
            }).catch(error => {
                layer.msg(error.message);
            })
        },
        toWeChatLogin:function () {
          //请求微信登录接口
          location.href="WeChat/towx_login";
        },
        toQQLogin:function () {
            //请求QQ登录接口
            location.href="toQQLogin";
        }
    }
});